package com.study.www.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.study.www.enums.ValidateParams;
import lombok.Data;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.util.Date;

/**
 * 用户查询对象
 * @author : 89007337.zhuyanpeng
 * @Description: :
 * @date :Create in  2019/6/27- 21:11
 * @Version: V1.0
 * @Modified By:
 **/
@Data
@ToString
public class UserVo {

    private String id;

    @Size(max = 9,min = 2,message = "名称只允许出现英文数字等的混合，且长度不可小于2或大于9",
    groups = {DeptVo.Add.class})
    @Pattern(regexp = ValidateParams.validateNameStr,message = "名称只允许出现英文数字等的混合，且长度不可小于2或大于9",
            groups = {Search.class,DeptVo.Add.class})
    private String name;

    @NotNull(message = "年龄不可为空",
            groups = {DeptVo.Add.class})
    @Min(value = 5,message = "年龄不可小于5",
            groups = {Search.class,DeptVo.Add.class})
    @Max(value = 150,message = "年龄不可大于150",
            groups = {Search.class,DeptVo.Add.class})
    private Integer age;

    @NotNull(message = "注册时间需要是过去时间")
    @Past(message = "注册时间需要是过去时间")
    private Date registerTime;

    @NotNull(message = "有效时间需要是将来时间",groups = {DeptVo.Add.class})
    @Future(message = "有效时间需要是将来时间",groups = {DeptVo.Add.class})
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date validateTime;

    private String deptId;

    public interface  Search{}

}
